<template>
	<!-- <z-paging ref="paging" v-model="list" @query="getDatas" :loading-more-enabled="false"> -->
	<view>
		<view class="d-p-r-30 d-p-l-30" style="">
			<u-search @search="search" @custom="search" placeholder="请输入学工号" :showAction="true" v-model="valsearch">
			</u-search>
		</view>
		<view class="d-p-l-30 d-p-r-30">
			<view class="d-flex d-p-t-20 d-p-b-20">
				<image :src="list.member_photo" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;">
				</image>
				<view class="d-flex-1 d-p-l-20">
					<view class="d-flex">
						<view class="d-flex-1">
							<view class="d-font-28">{{list.member_name}}</view>
							<view class="d-font-26 d-be d-m-t-10">{{list.member_type}}</view>
						</view>
						<!-- <view class="d-flex">
							<view class="d-m-r-38" @click="addFamily(item.member_id)"><u-image src="/static/e.png" width="28rpx" height="28rpx"></u-image></view>
							<view @click="(actionId = item.member_id), (show.del = true)"><u-image src="/static/d.png" width="28rpx" height="28rpx"></u-image></view>
						</view> -->
					</view>
				</view>
			</view>
		</view>
		<!-- <d-mode :show="show.del" content="确认删除此家属吗？" @cancel="confirmDel" @confirm="show.del = false" cancel-text="确认删除" confirm-text="我再想想"></d-mode> -->
		<!-- <template slot="bottom"> -->
		<view class="d-bottom">
			<view class="d-p-l-30 d-p-r-30 d-p-b-20 d-p-t-20">
				<u-button type="primary" shape="circle" :custom-style="{
							height: '80rpx',
							fontSize: '30rpx',
							background: '#59A0FF'
						}" @click="addFamily">
					确定添加
				</u-button>
			</view>
		</view>
		<!-- </template> -->
	</view>
	<!-- </z-paging> -->
</template>

<script>
	import {
		getMemberList,
		createFriend
	} from '@/common/api';
	export default {
		data() {
			return {
				list: {},
				show: {
					del: false
				},
				actionId: '',
				valsearch: '',
				val: ''
			};
		},
		onShow() {
			try {
				this.$refs.paging.reload(false)
			} catch (e) {}
		},
		methods: {
			getData() {
				getMemberList({
						member_id: this.val
					})
					.then(res => {
						console.log(res, '798')
						this.list = res
					})
			},
			confirmDel() {
				this.show.del = false;
				mDel({
					member_id: this.actionId
				}).then(res => {
					uni.$u.toast('已删除');
					this.$refs.paging.reload(false);
				});
			},
			addFamily() {
				if (!this.list.member_id) {
					uni.$u.toast('请输入学工号');
					return;
				}
				createFriend({
						his_member_id: this.list.member_id,
						his_member_name: this.list.member_name,
						avatar: this.list.member_photo,
						his_member_type: this.list.member_type,
					})
					.then(res => {
						console.log(res, '798')
						uni.$u.toast('添加成功');
						setTimeout(() => {
							uni.navigateBack({
								delta: 1, //返回层数，2则上上页
							})
						}, 2000)
					})
			},
			// 搜索字
			search(val) {
				console.log(val)
				this.val = val
				// this.page = 1;
				// this.ordersList = [];
				this.getData()
			},
		}
	};
</script>

<style lang="scss" scoped>
	.d-be {
		color: #bebebe;
	}

	.d-bottom {
		position: absolute;
		bottom: 0;
		width: 100%;
	}
</style>